package com.jeecms.edu.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jeecms.edu.entity.SchoolInformation;

/**
 * Servlet implementation class IndexDetail
 */
@WebServlet("/IndexDetail")
public class IndexDetail extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String callback=request.getParameter("callback");
//		String schoolname=new String(request.getParameter("schoolname").getBytes("ISO8859-1"),"UTF-8");
		String schoolname=request.getParameter("schoolname");
//		System.out.println(schoolname);
		String enrollment=SchoolInformation.checkSchoolEnrollment(schoolname);
		request.getSession().getServletContext().setAttribute("enrollment", enrollment);
		String schoolurl=SchoolInformation.checkSchoolUrl(schoolname);
		request.getSession().getServletContext().setAttribute("schoolurl", schoolurl);
		Map map=SchoolInformation.checkUnableSchoolDetail(schoolname);
		PrintWriter out=response.getWriter();
//		System.out.println(schoolname+map);
		if (null!=map) {
			request.getSession().getServletContext().setAttribute("schooldetail", map);
			String output = callback + "(0)";  
			response.setContentType("text/javascript");  
			out.println(output);  
		}else{
			String output = callback + "(0)";  
			response.setContentType("text/javascript");  
			out.println(output);  
		}
	}

}
